﻿using Microsoft.Synchronization.Data;
using SyncApp.RemoteProvider.RemoteSyncProviders;
using System;

namespace SyncApp.RemoteProvider
{

    //database sample
    //http://msdn.microsoft.com/es-es/library/bb726041.aspx
    public class CustomRemoteProviderSample : AppRemoteProviderSS2005
    {

        /// <summary>
        /// Initializes the sync adapters.
        /// </summary>
        public override void InitializeSyncAdapters()
        {
            try
            {
                AddSyncAdapter("Sales.Customer", SyncDirection.Bidirectional);
                AddSyncAdapter("Sales.CustomerContact", SyncDirection.UploadOnly);
            }
            catch (Exception e)
            {
                throw e;
            }


            //set here your conflict handler
            this.ApplyChangeFailed += new System.EventHandler<ApplyChangeFailedEventArgs>(CustomRemoteProviderSample_ApplyChangeFailed);
        }

        void CustomRemoteProviderSample_ApplyChangeFailed(object sender, ApplyChangeFailedEventArgs e)
        {
            throw new System.NotImplementedException();
        }
    }

    public class ChangeTrackingRemoteProviderSample : AppRemoteProviderSS2008
    {

        /// <summary>
        /// Initializes the sync adapters.
        /// </summary>
        public override void InitializeSyncAdapters()
        {
            try
            {
                AddSyncAdapter("Sales.Customer", SyncDirection.Bidirectional);
                AddSyncAdapter("Sales.CustomerContact", SyncDirection.UploadOnly);
            }
            catch (Exception e)
            {
                throw e;
            }
        }
    }

}